#include "map_height.h"

MapHeight::MapHeight(PNM* img) :
    Transformation(img)
{
}

MapHeight::MapHeight(PNM* img, ImageViewer* iv) :
    Transformation(img, iv)
{
}

PNM* MapHeight::transform()
{
    int width  = image->width(),
        height = image->height();

    PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);

	for (int i = 0; i < width; i++)
	{
		for (int j = 0; j < height; j++)
		{
			auto p = image->pixel(i, j);
			auto gray = qGray(p);
			newImage->setPixel(i, j, gray);
		}
	}

    return newImage;
}
